home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 1.9 KB | 85 lines | [TEXT/MPS ] |
- (*
- CTBTerminalInput string -- Feed the string to the terminal emulator, independent of any other input.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBTerminalInput.p
- link -m ENTRYPOINT -o HyperCommands -rt XCMD=2764 -sn Main=CTBTerminalInput ∂
- CTBTerminalInput.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBTerminalInput } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBTerminalInput(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBTerminalInput(paramPtr);
- end;
-
- procedure CTBTerminalInput(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var p: Ptr;
- l, l2: longInt;
- h: Handle;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBTerminalInput);
- end;
-
- begin
- { Check the parameter count. }
- if paramPtr^.paramCount <> 1 then Fail('Invalid parameter count');
-
- { Check for an empty string being sent. }
- if not ParmPresent(1) then exit(CTBTerminalInput);
- h := paramPtr^.params[1];
-
- { Make sure we've got the Comm Toolbox around. }
- CTBReady;
- { And that there's a terminal tool. }
- EnsurePresent(terminalTool);
-
- { Get the size of the input. }
- HLock(h);
- p := h^;
- l := 0;
- while p^ <> 0 do
- begin
- p := Ptr(ord4(p)+1);
- l := l+1;
- end;
- p := h^;
- { Feed it to the terminal tool (even it is won't take in one gulp). }
- while l > 0 do
- begin
- l2 := TMStream(Globals^^.termHand,p,l,0);
- p := Ptr(ord4(p)+l2);
- l := l - l2;
- end;
- HUnlock(h);
- end;
-
- end.
-